<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
	<head>
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta charset="UTF-8">
		<title>共富网-红包</title>
		<link href="/game/redpack/css/redPacket.css" type="text/css"
			rel="stylesheet" />
		<script src="/v3/js/jquery-1.10.2.min.js"></script>

	</head>
	<body>
		<div class="wztkjPopUpBox" style="display: none;">
			<div class="wztkjPopUpBoxMain">
				<div class="wztkjPopUpBoxContent1">
					<img src="/game/redpack/images/popUpBoxMark_03_06.png" />
				</div>
				<div class="wztkjPopUpboxBg">
					<div class="wztkjPopUpBoxContent2"></div>
					<div class="wztkjPopUpBoxContent3">
						<p class="wztkjPopUpboxP">
							取消
						</p>
						<p class="wztkjPopUpboxP1">
							确定
						</p>
						<div style="display: none;"></div>
					</div>
					<div class="wztkjPopUpBoxContent4" style="display: none;">
						确定
					</div>
				</div>
			</div>
		</div>

		<div class="robAfterMain">
			<div class="sendEnvelopes">
				<ul class="sendEnvelopes-header">
					<li class="sendEnvelopes-header-on" id="hb1" onclick="sethbtype(1)">
						发出的红包
					</li>
					<li id="hb2" onclick="sethbtype(2)">
						抢到的红包
					</li>
				</ul>
				<div class="sendEnvelopes-main" id="payTopList">

					<div class="wztSurplusHead">
						<c:choose>
							<c:when test="${not empty wechatInfoMap}">
								<img src="${wechatInfoMap.headimgurl }" />
							</c:when>
							<c:otherwise>
								<img src="/game/redpack/images/0.png" />
							</c:otherwise>
						</c:choose>
					</div>
					<div class="sendEnvelopes-tips">
						<span>共发出：</span>
						<b>${empty shareRpStatisticsMap.moneySum ? 0:shareRpStatisticsMap.moneySum }</b>
						<i>元</i>
					</div>
					<div class="sendEnvelopes-out">
						<span>发出红包：</span>
						<b>${empty shareRpStatisticsMap.shareCount ? 0:shareRpStatisticsMap.shareCount}</b>
						<span>个</span>
					</div>
					
				</div>
				<div class="sendEnvelopes-main" id="receiveTopList"
					style="display: none;">

					<div class="wztSurplusHead">
						<c:choose>
							<c:when test="${not empty wechatInfoMap}">
								<img src="${wechatInfoMap.headimgurl }" />
							</c:when>
							<c:otherwise>
								<img src="/game/redpack/images/0.png" />
							</c:otherwise>
						</c:choose>
					</div>
					<div class="sendEnvelopes-tips">
						<span>共抢到：</span><b>${empty gainRpStatisticsMap.moneySum ? 0:gainRpStatisticsMap.moneySum }</b><i>元</i>
					</div>
					<div class="sendEnvelopes-out">
						<span>收到红包：</span><b>${empty gainRpStatisticsMap.gainCounts ? 0:gainRpStatisticsMap.gainCounts }</b><span>个</span>
						<em class="sendEnvelopes-spacing"></em>
						<span>手气最佳：</span><b>${empty gainRpStatisticsMap.bestCounts ? 0:gainRpStatisticsMap.bestCounts }</b><span>次</span>
					</div>
					<div class="sendEnvelopes-btn">
						<a href="/redPackInit.do">立即发红包</a>
					</div>
				</div>
			</div>
		</div>
		<div id="receiveTopList1"></div>
		<div id="payTopList1"></div>
		
		<div class="robAfterBintbBottom useRBottom">
			<a href="/showMyRedpackList.do" class="robAfterMbBintContent">使用红包体验金投资</a>
		</div>
		
		<input type="hidden" name="stype" value="2" id="stype" />
		<input type="hidden" name="pageNo" value="1" id="pageNo" />
		<input type="hidden" name="totalpage" value="1" id="totalpage" />
		<script type="text/javascript"
			src="/game/redpack/js/jquery.hbalerts.js"></script>
		<script type="text/javascript">
	$(function (){
		var $li=$('.sendEnvelopes-header li');
		var $cen=$('.sendEnvelopes-main');
		$li.click(function(){
			if(!$(this).hasClass('sendEnvelopes-header-on')){
				$(this).addClass('sendEnvelopes-header-on').siblings().removeClass('sendEnvelopes-header-on');
				var index=$(this).index();
				$cen.hide().eq(index).show();
			}
		});

	});
	
  	function sethbtype(id){
  		$('#stype').val(id);
  		if(id==1){
  			$('#hb2').attr("class", "");
  			$('#hb1').attr("class", "sendEnvelopes-header-on");
  			$('#payTopList').show();
  			$('#payTopList1').show();
  			$('#receiveTopList').hide();
  			$('#receiveTopList1').hide();
  		}else{
  			$('#hb1').attr("class", "");
  			$('#hb2').attr("class", "sendEnvelopes-header-on");
  			$('#payTopList').hide();
  			$('#payTopList1').hide();
  			$('#receiveTopList').show();
  			$('#receiveTopList1').show();
  		}
  		ajaxusergainlist(id,1);
  	}
  	var ajaxpageno = 0;
  	function ajaxusergainlist(type,pageNo){
		if(pageNo){
			ajaxpageno = pageNo; 
			var myurl = '/userRedpackList.do?stype='+type+'&pageNo='+pageNo;
			 $.ajax({
		         url: myurl,
		         type: "POST",
		         success: function(data) {
				 	 $('#pageNo').val(data.pageNo);
     		 		 $('#totalpage').val(data.totalpage);
		        	 if(type==2){
		        		 	var htmlStr = '';
						 	var list = data.lists;
						 	if(data.pageNo <= 1){
						 		htmlStr += '<ul class="gPriceList" id="receiveUl">';
						 	}
						    if(list.length > 0){
						        for(var i=0,len=list.length;i<len;i++){
						        	htmlStr += '<li onclick="location.href=\'/gainllredpack.do?senvKey=' + list[i].senv_key + '\'">';
						        	htmlStr += '<div class="hImage"><img src="' + list[i].shareHeadimgurl + '" width="50" height="50"/></div>';
						        	htmlStr += '<div class="nName-Time-Money"><div class="gTop">';
						        	htmlStr += '<div class="uName">' + list[i].shareNickname + '</div>';
						        	htmlStr += '<div class="gMoney">' + list[i].valMoney + '元</div>';
						        	htmlStr += '</div>';
						        	htmlStr += '<div class="gBottom">';
						        	htmlStr += '<div class="gTime">' + list[i].createTimeFormat + '</div>';
						        	if(list[i].isMax == 1){
						        		htmlStr += '<div class="gBest"><i class="icon-Best"></i>手气最佳</div>';	
						        	}
						        	htmlStr += '</div>';
						        	htmlStr += '</div>';
						        	htmlStr += '</li>';
						        }
						    }
						    
						    if(data.pageNo > 1){
						    	$('#receiveUl').append(htmlStr);
							}else{
								htmlStr += '</ul>';
						  		$('#receiveTopList1').html(htmlStr);
						    }
		        	 }else{
		        		 	var htmlStr = '';
						 	var list = data.lists;
						 	if(data.pageNo <= 1){
						 		htmlStr += '<ul class="gPriceList" id="payUl">';
						 	}
						    if(list.length > 0){
						        for(var i=0,len=list.length;i<len;i++){
						        	htmlStr += '<li onclick="location.href=\'/gainllredpack.do?senvKey=' + list[i].senv_key + '\'">';
						        	htmlStr += '<div class="pMoneyList"><div class="gTop">';
						        	if(list[i].env_type == 1){
						        		htmlStr += '<div class="uName">普通红包</div>';
						        	}else{
						        		htmlStr += '<div class="uName">拼手气红包</div>';
						        	}
						        	if(list[i].env_type == 1){
						        		htmlStr += '<div class="gMoney">' + list[i].money * list[i].env_count + '元</div>';
							        }else{
							        	htmlStr += '<div class="gMoney">' + list[i].money + '元</div>';	
							        }
						        	htmlStr += '</div>';
						        	htmlStr += '<div class="gBottom">';
						        	htmlStr += '<div class="gTime">' + list[i].createTimeFormat + '</div>';
						        	htmlStr += '<div class="gSum">已领完' + list[i].has_count + '/' + list[i].env_count +'个</div>'
						        	htmlStr += '</div>';
						        	htmlStr += '</div>';
						        	htmlStr += '</li>';
						        }
						    }
						    
						    if(data.pageNo > 1){
						    	$('#payUl').append(htmlStr);
							}else{
								htmlStr += '</ul>';
		        				$('#payTopList1').html(htmlStr);
						    }
		        	 }
		        	
		         }
		      });
			}
	}
	$(function() {
		sethbtype(2);
		var hW = $(".hImage").width();
		var gW = $(".gPriceList").width();
		$(".nName-Time-Money").width(gW-hW-15);
		$(window).resize(function() {
			myWindowResize();
		})
		function myWindowResize() {
			var hW = $(".hImage").width();
			var gW = $(".gPriceList").width();
			$(".nName-Time-Money").width(gW-hW-15);
		}
	})
	
	$(window).scroll(function(){
		var stype = $('#stype').val();
		var scrollTop = $(this).scrollTop();
		var scrollHeight = $(document).height();
		var windowHeight = $(this).height();
		if(scrollTop + windowHeight >= scrollHeight){
			var totalpage = $("#totalpage").val();
			var no = $("#pageNo").val();
			var pageno = parseInt(no)+1;
			if(ajaxpageno!=pageno){
				if(totalpage != no){
					ajaxusergainlist(stype,pageno);
				}
			}
		}
	});
  </script>
	</body>
</html>